package com.erp.erp_servers.UserGroup.imp;

import com.erp.erp_dao.UserGroup.IUserGroupDAO;
import com.erp.erp_entitys.UserGroup.UserGroupEntity;
import com.erp.erp_entitys.UserGroup.UserGroupEntityExample;
import com.erp.erp_servers.UserGroup.IUserGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName ImpUserGroupService
 * @Description 用户缚实现类
 * @Author songjizhen
 * @Date 2020-07-03 23:37
 * @Version 1.0
 */
@Service
public class ImpUserGroupService implements IUserGroupService {
    @Autowired
    IUserGroupDAO userGroupDAO;
    /**
     * 新增用户组
     *
     * @param record
     * @return
     */
    @Override
    public int insertSelective(UserGroupEntity record) {
        return userGroupDAO.insertSelective(record);
    }

    /**
     * 删除用户组
     *
     * @param id
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Integer id) {
        return userGroupDAO.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteByExample(UserGroupEntityExample example) {

        return userGroupDAO.deleteByExample(example);
    }

    /**
     * 根据条件查询用户组
     *
     * @param record
     * @return
     */
    @Override
    public List<UserGroupEntity> selectByExample(UserGroupEntity record) {
        UserGroupEntityExample example =new UserGroupEntityExample ();
        UserGroupEntityExample.Criteria criteria = example.createCriteria();

        if(record.getCode() !=null){
            criteria.andCodeEqualTo(record.getCode());
        }

        List<UserGroupEntity> userGroupEntities = userGroupDAO.selectByExample(example);
        return userGroupEntities;
    }

    @Override
    public List<UserGroupEntity> selectByExample(UserGroupEntityExample example) {
        return userGroupDAO.selectByExample(example);
    }

    /**
     * 根据主键更新用户组
     *
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKeySelective(UserGroupEntity record) {
        return userGroupDAO.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据主键查询用户组
     *
     * @param id
     * @return
     */
    @Override
    public UserGroupEntity selectByPrimaryKey(Integer id) {
        return userGroupDAO.selectByPrimaryKey(id);
    }
}
